<template>
  <div class="app">
    <user-info @submit="onSubmit" title="登录">
      <div class="box">
        <router-link to="/register" class="link-right">跳转注册</router-link>
      </div>
    </user-info>
  </div>
</template>

<script>
import { login_API } from "@/api/user";
import UserInfo from "@/components/UserInfo.vue";
import { setToken } from "@/utils/local-storage";
export default {
  components: {
    UserInfo,
  },
  data() {
    return {};
  },
  methods: {
    async onSubmit(values) {
      const { data } = await login_API(values);
      if (data.code === 10000) this.$toast.success("登录成功");
      if (data.data.token) setToken(data.data.token);
      this.$router.push({
        path: "/Layout/Article",
      });
    },
  },
};
</script>

<style scoped>
</style>